package view.Listener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenuItem;

import view.LoginView;
import view.MainView;
import view.book.AddBookView;
import view.book.BorrowBookView;
import view.book.EditBookView;
import view.book.ReturnBookView;
import view.book.QueryBookView;
import view.type.AddTypeView;
import view.type.EditTypeView;
import view.user.AddUserView;
import view.user.EditUserView;
import view.user.UpPassView;

/**
 * @Author: Lin Hongwei
 * @LastEditors: Lin Hongwei
 * @email: 1365755396@qq.com
 * @CSDN: https://blog.csdn.net/weixin_45429409
 * @Description: 菜单栏事件接口监听
 *
 */
public class MainMenuBarListener implements ActionListener {
	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		JMenuItem jMenuItem = (JMenuItem)e.getSource();
		System.out.println("事件触发："+jMenuItem.getText());
		String name = jMenuItem.getText();
		if(name.equals("添加类别")) {
//			new AddTypeView(MainView.getContentJPane());
			MainView.setView(new AddTypeView());
		}
		if(name.equals("删除与修改类别")) {
			MainView.setView(new EditTypeView());
		}
		if(name.equals("添加图书")) {
			MainView.setView(new AddBookView());
		}
		if(name.equals("删除与修改图书")) {
			MainView.setView(new EditBookView());
		}
		if(name.equals("添加读者")) {
			MainView.setView(new AddUserView());
		}
		if(name.equals("删除与修改读者")) {
			MainView.setView(new EditUserView());
		}
		if(name.equals("借书")) {
			MainView.setView(new BorrowBookView());
		}
		if(name.equals("还书")) {
			MainView.setView(new ReturnBookView());
		}
		
		if(name.equals("查书")) {
			MainView.setView(new EditTypeView());
		}
		if(name.equals("图书查询")) {
			MainView.setView(new QueryBookView());
		}
		if(name.equals("修改密码")) {
			MainView.setView(new UpPassView());
		}
		
		
		
		
		if(name.equals("退出系统")) {
			MainView.instance.setVisible(false);
			MainView.setView(null);
			LoginView.instance.setVisible(true);
		}
		
		
		
	}

}
